﻿Imports Phila
Imports Phila.Sql
Imports Phila.CommonClasses
Imports Telerik.WebControls

Public Class ViewHotels
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Dim strSql As String
        'strSql = "select * from ptn_Hotels order by Id desc"
        'Fill_Grid_Bind(gvHotel, strSql)
    End Sub

    Protected Sub radGrid_DeleteCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles radGrid.DeleteCommand
        Dim ID As String = (CType(e.Item, GridDataItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ID").ToString
        Try
            Insert_Update_Delete_Record("delete from ptn_Hotels where id=" & ID)
        Catch ex As Exception
            'radGrid.Controls.Add(New LiteralControl(("Unable to Delete Record. Reason: " + ex.Message)))
            lblMsg.Text = "Unable to Delete Record. Reason: " + ex.Message
            lblMsg.ForeColor = Drawing.Color.Red
            e.Canceled = True
        End Try

    End Sub

    Protected Sub radGrid_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles radGrid.NeedDataSource
        Fill_Grid(radGrid, "SELECT [Id], [Name], (select Name from ptn_HotelCategory where Id=[CategoryId]) [CategoryId], [Address], [Phone], [Email], [Person], [City], [Region], [Country], [RoomCategory], [RoomType], [MealType], [Description], [MetaTitle], [MetaKeywords], [MetaDescription], [IsActive], [ViewOrder], [Thumbnail], [GMap], [Supplements] FROM [ptn_Hotels] order by City, Name")
    End Sub

    Protected Sub radGridExport_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles radGridExport.NeedDataSource
        Fill_Grid(radGridExport, "SELECT [Id], [Name], (select Name from ptn_HotelCategory where Id=[CategoryId]) [CategoryId], [Address], [Phone], [Email], [Person] FROM [ptn_Hotels] order by Vieworder, Name")
    End Sub

    Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click
        radGridExport.ExportSettings.ExportOnlyData = True
        radGridExport.ExportSettings.IgnorePaging = True
        radGridExport.ExportSettings.OpenInNewWindow = True
        radGridExport.MasterTableView.ExportToExcel2007("HotelDetails")
    End Sub
End Class